package de.tum.in.eist.im.client.Chat;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ScrollPanel;


class ChatBox extends Composite {
	
	private ScrollPanel scrollPanel = new ScrollPanel();
	private FlexTable messageTable = new FlexTable();
	
	
	public ChatBox(){
		scrollPanel.add(messageTable);
		
		initWidget(scrollPanel);
		
		setStyleName(".chatBox");
	}
	
	public void addMessage(String message) {
		    int numRows = messageTable.getRowCount();
		    messageTable.setWidget(numRows, 0, new HTML(message));
		    messageTable.getFlexCellFormatter().setRowSpan(0, 1, numRows + 1);
		    scrollPanel.scrollToBottom();
	}
}
